Git同时配置GitHub和Gitee 您所在的位置:网站首页 git webhook 登录 Git同时配置GitHub和Gitee

Git同时配置GitHub和Gitee

2023-06-26 11:05| 来源: 网络整理| 查看: 265

Git同时配置GitHub和Gitee

以下所有命令建议在 git bash 中完成

如果是之前没设置过的,就不用清除了。

可以通过git config --global --list来查看是否设置过。

git config --global --unset user.name "你的名字" git config --global --unset user.email "你的邮箱"

生成新的 SSH keys GitHub 的钥匙

ssh-keygen -t rsa -f ~/.ssh/id_rsa.github -C "[email protected]"

疯狂回车即可。

Gitee 的钥匙 邮箱换一个。不要跟上面相同就行了。

ssh-keygen -t rsa -f ~/.ssh/id_rsa.gitee -C "[email protected]"

疯狂回车即可。

完成后会在~/.ssh / 目录下生成以下文件。

id_rsa.github

id_rsa.github.pub

id_rsa.gitee

id_rsa.gitee.pub

识别 SSH keys 新的私钥 默认只读取 id_rsa,为了让 SSH 识别新的私钥,需要将新的私钥加入到 SSH agent 中

ssh-agent bash ssh-add ~/.ssh/id_rsa.github ssh-add ~/.ssh/id_rsa.gitee

多账号配置 config 文件

创建config文件

touch ~/.ssh/config

config 中填写的内容

#Default gitHub user Self Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa.github gitee Host gitee.com Port 22 HostName gitee.com User git IdentityFile ~/.ssh/id_rsa.gitee

添加 ssh https://github.com/settings/keys

将 id_rsa.github.pub 中的内容填进去,起名的话随意。

https://gitee.com/profile/sshkeys

将 id_rsa.gitee.pub 中的内容填进去,起名的话随意。

测试成功 ssh -T [email protected] ssh -T [email protected] 第一次会连接让你输入yes/no ,输入yes,就能看到Hi了。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有